package com.jarvan.service.impl;

import com.jarvan.model.Record;
import com.jarvan.repository.RecordRepository;
import com.jarvan.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordServiceImpl implements RecordService {

    @Autowired
    private RecordRepository repository;

    @Override
    public Record save(Record record) {
        return repository.save(record);
    }

    @Override
    public List<Record> findByStatus(Integer seatStatus) {
        return repository.findAllBySeatStatus(seatStatus);
    }

    @Override
    public Record findByTrainId(String trainId, String departureDate) {
        return repository.findFirstByDepartureDateAndBindTrain(departureDate, trainId);
    }

    @Override
    public List<Record> findByDate(String departureDate) {
        return repository.findAllByDepartureDate(departureDate);
    }
}
